#include "s3c2440_soc.h"

int uart0_init(void)
{
	/* 引脚初始化 */
	GPHCON &= ~((3<<4) | (3<<6));
	GPHCON |= ((2<<4) | (2<<6));

	GPHUP &= ~((1<<2) | (1<<3));  /* 使能内部上拉 */
	
	/* uart寄存器设置 */
	/* UBRDIVn = (int)( UART clock / ( buad rate x 16) ) –1 */
	ULCON0 = 0x3;
	UCON0  = 0x5;
	UBRDIV0  = 26;
}

int putchar(int c)
{
	/* UTRSTAT0 UTXH0*/
	while(!(UTRSTAT0 & (1<<2)));
	UTXH0 = (unsigned char)c;
}

int getchar(void)
{
	/* URXH0 */
	while(!(UTRSTAT0 & (1<<0)));
	return URXH0;
}

int puts(const char *s)
{
	while(s)
	{
		putchar(*s);
		s++;
	}
}

